// 用户相关 api
import request from '@/util/request'

export function login(data) {
  return request({
    method: 'post',
    url: '/api/users/login',
    data
  })
}

export function register(data) {
  return request({
    method: 'post',
    url: '/api/users',
    data
  })
}

export function getAuthor(username) {
  return request({
    method: 'GET',
    url: `/api/profiles/${username}`
  })
}

export function followUser(username) {
  return request({
    method: 'POST',
    url: `/api/profiles/${username}/follow`
  })
}

export function unfollowUser(username) {
  return request({
    method: 'DELETE',
    url: `/api/profiles/${username}/follow`
  })
}

export function getUser() {
  return request({
    method: 'GET',
    url: '/api/user'
  })
}

export function updateSetting(data) {
  return request({
    method: 'PUT',
    url: '/api/user',
    data
  })
}